package summer_vacation.zengguangchuan;

import java.util.Scanner;

/**作业32
 * Created by lenovo0 on 2015/8/31.
 */
public class Assignment_13 {
    public static void main(String[] args){
        System.out.print("请输入一个四位数的正整数：");
        Scanner input=new Scanner(System.in);
        int i=input.nextInt();
        int a,b,c,d;
        d=i%10;
        c=(i-d)%100/10;
        b=(i-d-c)%1000/100;
        a=(i-d-c*10-b*100)/1000;
        int sum=0;
        sum=a*a+b*b+c*c+d*d;
        System.out.println(sum);
    }
}
